//关闭广告
document.querySelector('.close').onclick = function(){
    document.querySelector('.ggtl').style.display = 'none';
}

//回顶部

let top2 = document.querySelector('.f-top');
window.onscroll = function(){
    if(window.pageYOffset>600){
        top2.style.display = 'flex';
    }else{
        top2.style.display = 'none';
    }
}

//轮播图区域 开始
let box = document.querySelector('.banner .box');
let lis = document.querySelectorAll('.box .image li');
let licu = document.querySelectorAll('.num li');

//获取元素 注册事件 
let left = document.querySelector('.box .left');
let right = document.querySelector('.box .right');


for(let lisl = 0;lisl<lis.length;lisl++){
    lis[0].style.display = 'flex';
    licu[0].className = 'current';
    lis[lisl].style.display = 'none';
}

// 左箭头控制轮播
left.onclick = function(){
   for(let lisl = lis.length-1;;){
        if(lis[lisl].style.display == 'flex'){
            licu[lisl].setAttribute('class','');
            lis[lisl].style.display = 'none';
            if(lisl == 0){
                lisl = lis.length-1;
                lis[lisl].style.display = 'flex';
                licu[lisl].className = 'current';
            }else{
                lis[lisl-1].style.display = 'flex';
                licu[lisl-1].className = 'current';
            }
            break;
        }

        if(lisl ==0 ){
            lisl = lis.length-1;
        }else{
            lisl--;
        }
   }
}


// 右箭头控制轮播

right.onclick = function(){
    for(let lisl = 0;;){
         if(lis[lisl].style.display == 'flex'){
            licu[lisl].setAttribute('class','');
            lis[lisl].style.display = 'none';
            if(lisl == lis.length-1){
                lisl = 0;
                lis[lisl].style.display = 'flex';
                licu[lisl].className = 'current';
            }else{
                lis[lisl+1].style.display = 'flex';
                licu[lisl+1].className = 'current';
            }
             break;
         }
         if(lisl ==lis.length-1 ){
             lisl = 0;
         }else{
            lisl++;
         }
    }
 }



// 自动轮播
function timee(){
    return setInterval(function(){
        for(let lisl = 0;;){
            if(lis[lisl].style.display == 'flex'){
            licu[lisl].setAttribute('class','');
            lis[lisl].style.display = 'none';
            if(lisl == lis.length-1){
                lisl = 0;
                lis[lisl].style.display = 'flex';
                licu[lisl].className = 'current';
            }else{
                lis[lisl+1].style.display = 'flex';
                licu[lisl+1].className = 'current';
            }
                break;
            }
            if(lisl ==lis.length-1 ){
                lisl = 0;
            }else{
            lisl++;
            }
        }

    },2000)
}
let timeer = timee();
// 鼠标移入清除定时器
box.onmouseover = function(){
    clearInterval(timeer);
} 
//移出启动计时器
box.onmouseout = function(){
    timeer = timee();
}

//图片轮播和提示信息

//轮播图区域 结束
